﻿using AOT.Game.Timer;

namespace Net.Runtime.Base
{
    /// <summary>
    /// 提供给上层的 c/s接口
    /// A.提供基础生命周期
    /// </summary>
    public abstract class BaseRpc
    {
        protected ScriptTimer timer;
        private float UPDATE_DELTA_TIME = 0.2f;
        private long updateTimer = -1;
        public virtual void OnStart(ScriptTimer _timer,string ip, int port)
        {
            timer = _timer;
            updateTimer = timer.DoThingPeriod(UPDATE_DELTA_TIME, OnUpdate);
        }

        public virtual void OnStart(ScriptTimer _timer, string ip, int port, int maxConnectNum)
        {
            timer = _timer;
            updateTimer = timer.DoThingPeriod(UPDATE_DELTA_TIME, OnUpdate);
        }
        
        public virtual void OnUpdate()
        {
            
        }

        public virtual void OnClose()
        {
            timer.TryStopTimerById(updateTimer);
        }
    }
}